/*
Abstract:
  Basic types declaration

Last changed:
  $Id: types.h 67 2009-04-13 08:26:23Z vitamin.caig $

Author:
  (C) Vitamin/CAIG/2001

  This file is the part of Textator project
*/
#ifndef __TYPES_H_DEFINED__
#define __TYPES_H_DEFINED__

#include "format.h"

#include <map>
#include <list>
#include <string>
#include <vector>
#include <istream>
#include <ostream>

#ifdef UNICODE
template<class F, class T>
inline T StringConvert(const F& fs)
{
  T res(fs.size(), '\0');
  std::copy(fs.begin(), fs.end(), res.begin());
  return res;
}

typedef std::wstring String;
typedef std::wistream InStream;
typedef std::wostream OutStream;

inline String FromStdString(const std::string& str)
{
  return StringConvert<std::string, String>(str);
}

inline std::string ToStdString(const String& str)
{
  return StringConvert<String, std::string>(str);
}

extern InStream& StdIn;
extern OutStream& StdOut;
extern OutStream& StdErr;
#else
typedef std::string String;
typedef std::istream InStream;
typedef std::ostream OutStream;

inline String FromStdString(const std::string& str)
{
  return str;
}

inline std::string ToStdString(const String& str)
{
  return str;
}
extern InStream& StdIn;
extern OutStream& StdOut;
extern OutStream& StdErr;
#endif

//common types
typedef std::basic_ostringstream<String::value_type> OStringStream;
typedef std::map<String, String> StringMap;
typedef std::vector<String> StringArray;
typedef std::list<String> StringList;
typedef Formatter<String> StringFormatter;

#endif //__TYPES_H_DEFINED__
